package com.sinopec.android;


import java.util.ArrayList;

import com.sinopec.android.constant.ConfigAttrs;
import com.sinopec.android.constant.Constants;
import com.sinopec.android.util.SharePreferencesUtil;
import com.sinopec.android.util.StringUtil;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.WindowManager;

public class BaseActivity extends Activity {
	
	public  int screen_height = 0; 
	public  int screen_width = 0; 
	public  String deviceId ;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		if(Constants.activityList == null){
			Constants.activityList = new ArrayList<Activity>();
		}
		Constants.activityList.add(this);
		try{
			WindowManager wm = (WindowManager) getWindowManager();
			screen_height = wm.getDefaultDisplay().getHeight();
			screen_width =  wm.getDefaultDisplay().getWidth();
			// 创建电话管理
			TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
			// 获取手机号码
			deviceId = tm.getDeviceId();
		}catch (Exception e) {
			e.printStackTrace();
		}
		if(StringUtil.isNotEmpty(SharePreferencesUtil.getIP(this, ConfigAttrs.SET_IP))){
			ConfigAttrs.BASE_IP = SharePreferencesUtil.getIP(this, ConfigAttrs.SET_IP);
		}
		
		ConfigAttrs.BASE_URL = "http://"+ConfigAttrs.BASE_IP+"/ForMobile/";
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if(Constants.activityList != null&&Constants.activityList.contains(this)){
			Constants.activityList.remove(this);
		}
	}

	
	
}
